#incoding=utf-8
from django.db import models
import datetime
# Create your models here.
class Sort(models.Model):
    name = models.CharField('分类', max_length=100)
    #level = models.IntegerField('分类级别', choices=(('0', '一级分类'), ('1', '二级分类')), blank=True, null=True)
    
class Book(models.Model):
    sort = models.ForeignKey(Sort)
    money = models.IntegerField('金额(元)')
    describe = models.CharField('描述', max_length=300, blank=True, null=True)
    date = models.DateField('填写日期')
    item = models.CharField('金额类型', choices=(('1', '收入'), ('2', '支出')), max_length=10)
    
from django.contrib import admin
from pydemo.book.models import Sort, Book

class BookAdmin(admin.ModelAdmin):
    list_display = ['money','describe','date','item','sort']
    list_filter = ['item','sort']
    #search_fields = ['sort','item']

admin.site.register(Book,BookAdmin)
    
class SortAdmin(admin.ModelAdmin):
    list_display = ['name']
      
    
admin.site.register(Sort, SortAdmin) 